<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  ~ Copyright (c) 2018. QDU 2015 Java1 Team CompilationError
  --%>

<%--
  Created by IntelliJ IDEA.
  User: inkux
  Date: 2018/6/11
  Time: 14:53
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<html>
<head>
	<title>Users</title>
	<%@include file="../resources/js_css_includes.jsp" %>
	<script src="${pageContext.request.contextPath}/js/user_manager.js"></script>
</head>
<body>
<%@include file="../resources/navigation_header.jsp" %>
<%@include file="../resources/jsp_body_preludes.jsp" %>

<div class="table_div_forall" id="user_manager_table_wrapper">
	<label class="none" for="filter_input">Filter by:</label>
	<select class="none" name="filter_select" id="filter_select">
		<option value="1">Username</option>
		<option value="3">Department</option>
		<option value="4">Designation</option>
		<option value="5">Permission</option>
		<option value="6">Mobile</option>
		<option value="7">Email</option>
	</select>
	<input class="none" id="filter_input" type="text">
	<button onclick="clearFilters()">Clear</button>
	<table id="user_manager_table" class="data_table">
	<thead>
	<tr>
		<th>ID</th>
		<th>Username</th>
		<th>Gender</th>
		<th>Department</th>
		<th>Designation</th>
		<th>Perm. Group</th>
		<th>Mobile</th>
		<th>Email</th>
		<th>Salary</th>
		<th>Operations</th>
	</tr>
	</thead>
	<tbody>
	<c:forEach var="user" items="${users}">
		<tr>
			<td>${user.id}</td>
			<td>${user.username}</td>
			<td>${user.gender}</td>
			<td>${departmentMap.get(user.departmentId).name}</td>
			<td>${designationMap.get(user.designationId).name}</td>
			<td>${permissionMap.get(user.permissionGroupId).groupName}</td>
			<td>${user.mobile}</td>
			<td>${user.email}</td>
			<td>${user.salary}</td>
			<td>
				<c:if test="${permissions.modifyUser}">
					<a href="#" onclick="confirmDeleteUser(${user.id})">Delete</a>
					<a href="./modify_user?id=${user.id}">Modify</a>
				</c:if>
			</td>
		</tr>
	</c:forEach>
	</tbody>
	</table>
	<p><i>Hold Ctrl to select multiple</i></p>
	<button class="btn_color1" onclick="confirmDeleteBatch()">Delete Selected</button>
	<p>
		<a class="btn_color2" href="${pageContext.request.contextPath}/admin/new_user">New User</a>
	</p>
</div>
</body>
</html>
